﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Product.aspx.cs" Inherits="Web.SearchPopUp.Product" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Product Search</title>
    <link rel="stylesheet" type="text/css" href="../CSS/style.css" />
    <link rel="stylesheet" type="text/css" href="../CSS/bootstrap.min.css" />
    <link href="../CSS/Fonts.css" rel='stylesheet' type='text/css' />
    <script src="../JS/jquery.min.js"></script>
    <script src="../JS/bootstrap.min.js"></script>
    <telerik:RadCodeBlock ID="RadCodeBlock" runat="server">
        <script type="text/javascript">
            function GetRadWindow() {
                var oWindow = null;
                if (window.radWindow) oWindow = window.radWindow;
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
                return oWindow;
            }
            function RowSelected(sender, eventArgs) {
                var grid = sender;
                var MasterTable = grid.get_masterTableView();
                var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
                var productImage = row.findElement("productImage");

                var oArg = new Object();
                oArg.SearchType = "Product";
                oArg.ProductImage = productImage.src;
                oArg.ProductID = eventArgs.getDataKeyValue("ID");
                oArg.ProductName = MasterTable.getCellByColumnUniqueName(row, "PRODUCT_NAME").innerHTML;
                oArg.ProductDes = MasterTable.getCellByColumnUniqueName(row, "DESCRIPTION").innerHTML.replace("&nbsp;", "");
                oArg.ProductGST = MasterTable.getCellByColumnUniqueName(row, "GST_PERCENT").innerHTML;
                oArg.ProductUnitPrice = MasterTable.getCellByColumnUniqueName(row, "UNIT_PRICE").innerHTML;
                oArg.ProductBalance = MasterTable.getCellByColumnUniqueName(row, "BALANCE").innerHTML;
                var oWnd = GetRadWindow();
                if (oArg.ProductID) {
                    oWnd.close(oArg);
                }
            }
            function onClose() {
                window.close();
            }
            function pageLoad(sender, eventArgs) {
                if (!eventArgs.get_isPartialLoad()) {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("InitialPageLoad");
                }
            }

        </script>
    </telerik:RadCodeBlock>
</head>
<body class="popup-body">
    <form id="form1" runat="server">
        <div>
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            </telerik:RadScriptManager>
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel2" runat="server" IsSticky="true" CssClass="MyModalPanel" Transparency="50" />
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="mainPanel" LoadingPanelID="RadAjaxLoadingPanel2" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="mainPanel">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="mainPanel" LoadingPanelID="RadAjaxLoadingPanel2" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <div id="mainContent">
                <asp:Panel ID="mainPanel" runat="server">
                    <asp:Panel ID="Panel1" runat="server" Style="display: none">
                        <div class="register" style="margin-top: 0">
                            <div class="container-fluid" style="padding-left: 30px; padding-right: 30px">
                                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                                    <div class="row">
                                        <div class="panel panel-default">
                                            <div class="panel-heading" role="tab" id="headingOne">
                                                <h4 class="panel-title">
                                                    <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">Search <i class="glyphicon glyphicon-circle-arrow-down" style="display: none;"></i><i class="glyphicon glyphicon-circle-arrow-up"></i>
                                                    </a>
                                                </h4>
                                            </div>
                                            <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
                                                <div class="panel-body">
                                                    <div class="firstrow">
                                                        <div class="edit-form">
                                                            <div class="control-group">
                                                                <div class="col-md-4 distance-control">
                                                                    <div class="col-md-4">
                                                                        <label class="control-label">Product Name </label>
                                                                    </div>
                                                                    <div class="col-md-8">
                                                                        <div class="controls">
                                                                            <asp:TextBox ID="txtProductName" runat="server" class="form-control" onkeypress="isPressEnter(event)" />
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <div class="col-md-4 distance-control">
                                                                    <div class="col-md-4">
                                                                        <label class="control-label">Part Number </label>
                                                                    </div>
                                                                    <div class="col-md-8">
                                                                        <div class="controls">
                                                                            <asp:TextBox ID="txtPartNumber" runat="server" class="form-control" onkeypress="isPressEnter(event)" />
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <div class="col-md-4 distance-control">
                                                                    <div class="col-md-4">
                                                                        <label class="control-label">Unit Price </label>
                                                                    </div>
                                                                    <div class="col-md-8">
                                                                        <div class="controls">
                                                                            <asp:TextBox ID="txtUnitPrice" runat="server" class="form-control" onkeypress="isPressEnter(event)" />
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <div class="clearfix"></div>
                                                            </div>
                                                            <div class="control-group">
                                                                <div class="col-md-4 distance-control">
                                                                    <div class="col-md-4">
                                                                        <label class="control-label">Date Created From </label>
                                                                    </div>
                                                                    <div class="col-md-8">
                                                                        <div class="controls">
                                                                            <telerik:RadDatePicker ID="dpDateCreatedFrom" runat="server" Width="70%">
                                                                                <DateInput ReadOnly="true" ID="RadDateInput1" runat="server">
                                                                                </DateInput>
                                                                                <Calendar ReadOnly="true" ID="Calendar1" runat="server" UseColumnHeadersAsSelectors="False"
                                                                                    UseRowHeadersAsSelectors="False" ViewSelectorText="x">
                                                                                    <SpecialDays>
                                                                                        <telerik:RadCalendarDay Repeatable="Today" ItemStyle-CssClass="rcToday">
                                                                                        </telerik:RadCalendarDay>
                                                                                    </SpecialDays>
                                                                                </Calendar>
                                                                            </telerik:RadDatePicker>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <div class="col-md-4 distance-control">
                                                                    <div class="col-md-4">
                                                                        <label class="control-label">Date Created To </label>
                                                                    </div>
                                                                    <div class="col-md-8">
                                                                        <div class="controls">
                                                                            <telerik:RadDatePicker ID="dpDateCreatedTo" runat="server" Width="70%">
                                                                                <DateInput ReadOnly="true" ID="DateInput2" runat="server">
                                                                                </DateInput>
                                                                                <Calendar ReadOnly="true" ID="Calendar2" runat="server" UseColumnHeadersAsSelectors="False"
                                                                                    UseRowHeadersAsSelectors="False" ViewSelectorText="x">
                                                                                    <SpecialDays>
                                                                                        <telerik:RadCalendarDay Repeatable="Today" ItemStyle-CssClass="rcToday">
                                                                                        </telerik:RadCalendarDay>
                                                                                    </SpecialDays>
                                                                                </Calendar>
                                                                            </telerik:RadDatePicker>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <div class="col-md-4 distance-control" id="divAssignTo" runat="server">
                                                                    <div class="col-md-4">
                                                                        <label class="control-label">Assign To </label>
                                                                    </div>
                                                                    <div class="col-md-8">
                                                                        <div class="controls">
                                                                            <telerik:RadComboBox ID="ddlAssignedTo" runat="server" class="form-control"
                                                                                Width="80%" Filter="StartsWith" MaxHeight="700px" />
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <div class="clearfix"></div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="popup-btn">
                                                        <div class="col-md-12 btn-edit">
                                                            <asp:LinkButton id="btnSearch" type="button" class="btn btn-defaul" runat="server" OnClick="btnSearch_ServerClick">
                                                                <img src="../Images/search.png" style="width: 20px; height: 20px" />
                                                                Search
                                                            </asp:LinkButton>
                                                            <button class="btn btn-defaul" type="button" onclick="return onClose();">
                                                                <img src="../Images/delete.png" style="width: 20px; height: 20px" />
                                                                Cancel
                                                            </button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="edit-form highlight">
                                            <div class="control-group">
                                                <h4>Products</h4>
                                            </div>
                                            <div style="width: 100%">
                                                <telerik:RadGrid ID="RadGrid1" ShowStatusBar="True" runat="server" AllowPaging="True" AllowSorting="True" AllowMultiRowSelection="True"
                                                    AutoGenerateColumns="False" GridLines="None" Width="100%" OnNeedDataSource="RadGrid1_NeedDataSource"
                                                    Font-Size="12px" EnableLinqExpressions="false" OnItemCreated="RadGrid1_ItemCreated">
                                                    <ClientSettings EnableRowHoverStyle="true">
                                                        <Selecting AllowRowSelect="True" />
                                                        <ClientEvents OnRowSelected="RowSelected" />
                                                    </ClientSettings>
                                                    <MasterTableView PageSize="10" NoDetailRecordsText="No records" NoMasterRecordsText="No records" ShowHeader="true" TableLayout="Fixed" ClientDataKeyNames="ID">
                                                        <Columns>
                                                            <%--<telerik:GridImageColumn UniqueName="GridImageColumn" DataType="System.String" DataImageUrlFields="IMAGE"
                                                    AlternateText="PRODUCT_NAME" DataAlternateTextField="PRODUCT_NAME"
                                                    ImageAlign="Middle" ImageHeight="80px" ImageWidth="80px" HeaderText="IMAGE">
                                                    <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="8.5%" />
                                                </telerik:GridImageColumn>--%>
                                                            <telerik:GridTemplateColumn HeaderText="Item Image" UniqueName="ITEM_IMAGE">
                                                                <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="80px" />
                                                                <ItemStyle HorizontalAlign="center" Width="80px" />
                                                                <FooterStyle HorizontalAlign="center" Width="80px" BackColor="LightBlue" Font-Bold="true" />
                                                                <ItemTemplate>
                                                                    <asp:Image ID="productImage" runat="server" ImageUrl='<%# Bind( "IMAGE") %>' Style="width: 80px; height: 80px" />
                                                                </ItemTemplate>
                                                            </telerik:GridTemplateColumn>
                                                            <telerik:GridBoundColumn DataField="PRODUCT_NAME" HeaderText="Product Name" UniqueName="PRODUCT_NAME" SortExpression="PRODUCT_NAME">
                                                                <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="20%" />
                                                                 <ItemStyle Wrap="false" HorizontalAlign="center" Width="20%" />
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn DataField="DESCRIPTION" HeaderText="Product Description" UniqueName="DESCRIPTION" SortExpression="DESCRIPTION" Display="false">
                                                                <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="18.5%" />
                                                                 <ItemStyle Wrap="false" HorizontalAlign="center" Width="20%" />
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn DataField="SERIAL_NO" HeaderText="Serial Number" UniqueName="SERIAL_NO" SortExpression="SERIAL_NO">
                                                                <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="8%" />
                                                                 <ItemStyle Wrap="false" HorizontalAlign="center" Width="8%" />
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn DataField="DATE_ENTERED" HeaderText="Date Created" UniqueName="DATE_ENTERED" SortExpression="DATE_ENTERED" DataFormatString="{0:d}" DataType="System.DateTime">
                                                                <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="10%" Font-Size="12px" />
                                                                <ItemStyle HorizontalAlign="center" Width="10%" Font-Size="12px" />
                                                                <FooterStyle HorizontalAlign="center" Width="10%" BackColor="LightBlue" />
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn DataField="SUPPORT_START_DATE" HeaderText="Support Start Date" UniqueName="SUPPORT_START_DATE" SortExpression="SUPPORT_START_DATE" DataFormatString="{0:d}" DataType="System.DateTime">
                                                                <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="7%" />
                                                                <ItemStyle HorizontalAlign="center" Width="7%" />
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn DataField="SUPPORT_EXPIRY_DATE" HeaderText="Support Expiry Date" UniqueName="SUPPORT_EXPIRY_DATE" SortExpression="SUPPORT_EXPIRY_DATE" DataFormatString="{0:d}" DataType="System.DateTime">
                                                                <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="8%" />
                                                                <ItemStyle HorizontalAlign="center" Width="8%" />
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridNumericColumn DataField="COMMISSION_RATE" HeaderText="Commission Rate(%)" UniqueName="COMMISSION_RATE" SortExpression="COMMISSION_RATE" NumericType="Percent" DataFormatString="{0:N2} %">
                                                                <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="8%" />
                                                                <ItemStyle HorizontalAlign="center" Width="8%" />
                                                            </telerik:GridNumericColumn>
                                                            <telerik:GridNumericColumn DataField="GST_PERCENT" HeaderText="GST" UniqueName="GST_PERCENT" SortExpression="GST_PERCENT" NumericType="Number" Display="false">
                                                                <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="7%" />
                                                                <ItemStyle HorizontalAlign="center" Width="7%" />
                                                            </telerik:GridNumericColumn>
                                                            <telerik:GridNumericColumn DataField="QTY_IN_STOCK" HeaderText="Qty. in Stock " UniqueName="QTY_IN_STOCK" SortExpression="QTY_IN_STOCK" NumericType="Number" DataFormatString="{0:N2}">
                                                                <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="7%" />
                                                                <ItemStyle HorizontalAlign="center" Width="7%" />
                                                            </telerik:GridNumericColumn>
                                                            <telerik:GridNumericColumn DataField="BALANCE" HeaderText="Balance" UniqueName="BALANCE" SortExpression="BALANCE" NumericType="Number">
                                                                <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="7%" />
                                                                <ItemStyle HorizontalAlign="center" Width="7%" />
                                                            </telerik:GridNumericColumn>
                                                            <telerik:GridNumericColumn DataField="UNIT_PRICE" HeaderText="Unit Price" UniqueName="UNIT_PRICE" SortExpression="UNIT_PRICE" NumericType="Currency" FooterAggregateFormatString="{0:C}">
                                                                <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="8%" />
                                                                <ItemStyle HorizontalAlign="center" Width="8%" />
                                                            </telerik:GridNumericColumn>
                                                            <telerik:GridBoundColumn DataField="ASSIGN_TO" HeaderText="Assigned To" UniqueName="ASSIGN_TO" SortExpression="ASSIGN_TO">
                                                                <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="10%" />
                                                                 <ItemStyle Wrap="false" HorizontalAlign="left" Width="10%" />
                                                            </telerik:GridBoundColumn>
                                                        </Columns>
                                                        <PagerStyle PageSizes="5,10,20,50" PagerTextFormat="{4}<strong>{5}</strong> products matching your search criteria"
                                                            PageSizeLabelText="Products per page:" AlwaysVisible="true" />
                                                    </MasterTableView>
                                                    <PagerStyle Mode="NumericPages"></PagerStyle>
                                                </telerik:RadGrid>
                                            </div>
                                        </div>
                                        <div class="clearfix"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </asp:Panel>
                </asp:Panel>
            </div>
        </div>
    </form>
</body>
</html>
